package cn.tedu.eb_film.security;

import cn.tedu.eb_film.utils.ResponseUtils;
import cn.tedu.eb_film.utils.ServiceCode;
import org.springframework.security.core.AuthenticationException;
import org.springframework.security.web.AuthenticationEntryPoint;
import org.springframework.stereotype.Component;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * 认证入口
 *
 * @author ライナー・ロンテ
 * @since 2023/3/7 14:23
 */
@Component
public class AuthenticationEntryPointImpl implements AuthenticationEntryPoint {
    @Override
    public void commence(HttpServletRequest request, HttpServletResponse response,
                         AuthenticationException authException)
            throws IOException, ServletException {
        System.out.println("认证失败回进入这里");
        ResponseUtils.sendResponse(response, ServiceCode.ERROR_UNKNOWN,"您当前未登录，请登录");
    }

}

